<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Franchise_suburbs_model extends CI_Model {

    public function loadFranchiseSuburbs($data = array(), $sort = array()) {
        $this->db->select("au_suburb_geo.*");
        $this->db->from("franchise_suburbs");
        $this->db->join("au_suburb_geo","franchise_suburbs.suburbs_id = au_suburb_geo.ID");
        if (!empty($data)) {
            foreach ($data as $key => $value) {
                $this->db->where($key, $value);
            }
        }

        if (!empty($sort)) {
            foreach ($sort as $key => $value) {
                $this->db->order_by($key, $value);
            }
        }
        $query = $this->db->get();

        return $query->result();
    }

    public function getSuburbById($id) {
        $result = $this->loadFranchiseSuburbs(array('id' => $id));
        if (!empty($result))
            return $result[0];
        return FALSE;
    }

}